home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / asm_subr.arc / DECNORM < prev    next >
Encoding:
Text File  |  1985-12-27  |  1.5 KB  |  57 lines

  1. ;-------------------------decnorm routine begins--------------------------+
  2. ; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
  3. ;         page : 99
  4. ;
  5. ; NAME  DECNORM
  6. ;
  7. ; ROUTINE FOR Normalization of Temporary Decimal Floating Point
  8. ;
  9. ; FUNCTION: This routine normalizes a temporary decimal floating point
  10. ; nuumber.
  11. ;
  12. ; INPUT: Upon entry DS:DI points to a temporary decimal floating point
  13. ; number.
  14. ;
  15. ; OUTPUT: Upon exit the temporary floating point number is normalized.
  16. ;
  17. ; REGISTERS USED:  AX, CX, and DI are modified.
  18. ;
  19. ; SEGMENTS REFERENCED:  The data segment contains storage for a temporary
  20. ; decimal floating point number
  21. ;
  22. ; ROUTINES CALLED:  None
  23. ;
  24. ; SPECIAL NOTES: Equates are used to shorten address fields.
  25. ;
  26. decnorm    proc    near
  27. ;
  28. ; check top + 1 digit
  29.     cmp    dibyte+22,0    ; is it already zero ?
  30.     je    decnorm2    ; if so exit
  31. ;
  32. ; round up starting with bottom digit
  33.     mov    al,[di]        ; first digit
  34.     add    al,al        ; double it for roundup
  35.     mov    ah,0        ; prepare carry
  36.     aaa            ; adjust for decimal
  37. ;
  38. ; now shift the rest
  39.     mov    cx,24        ; for a count of 24
  40. decnorm1:
  41.     mov    al,[di+1]    ; get next digit
  42.     add    al,ah        ; add carry
  43.     mov    ah,0        ; prepare next carry
  44.     aaa            ; adjust for decimal
  45.     mov    [di],al        ; put digit into place
  46.     inc    di        ; point to next digit
  47.     loop    decnorm1
  48. ;
  49.     inc    deexp        ; incrememt decimal exponent
  50. ;
  51. decnorm2:
  52. ;
  53.     ret            ; return
  54. ;
  55. decnorm    endp
  56. ;-------------------------decnorm routine ends---------------------------+
  57.